package com.neolix.watch;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewTreeObserver;

import com.neolix.watch.view.TestSurfaceView;
import com.neolix.watch.view.TestView;

import static com.google.common.primitives.Ints.asList;

public class TestActivity2 extends Activity {

    private boolean hadCreateGridView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);

        final TestSurfaceView viewById = (TestSurfaceView) findViewById(R.id.surface_view_test);

        ViewTreeObserver vto = viewById.getViewTreeObserver();
        vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            public boolean onPreDraw() {
                if (hadCreateGridView) {
                    return true;
                }
                viewById.setData(asList(2000, 4526, 3000, 6000, 3500, 4000, 2800));
                hadCreateGridView = true;
                return true;
            }
        });
    }
}
